import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { FormBuilder, FormGroup, Validators, FormControl } from "@angular/forms";
import { Observable } from "rxjs/Observable";
import { TurbStatusService } from "../../service/turbstatus.service";
@Component({
  selector: 'app-color-choices',
  templateUrl: './color-choices.component.html',
  styleUrls: ['./color-choices.component.css']
})
export class ColorChoicesComponent implements OnInit {
  validationMessages: {};
  formErrors: {};
  fromBuider: FormBuilder;
  @Input() currentEntity: any;
  @Output() colorOut = new EventEmitter();
  myGroup: FormGroup;
  constructor(private fb: FormBuilder, private turbastatusService: TurbStatusService) {
    this.myGroup = fb.group({
      statusColor: new FormControl(""),
    });
}

  ngOnInit() {
    this.myGroup.controls["statusColor"].setValue(this.currentEntity.statusColor)
    this.myGroup.controls["statusColor"].valueChanges
      .distinctUntilChanged()
      .subscribe((form: any) => {
        console.log(this.myGroup.valid)
        this.colorOut.emit({
          value: form,
          err:this.myGroup.valid
        });

      });



  }

  
}



// WEBPACK FOOTER //
// ./src/app/shared/color-choices/color-choices.component.ts